package mlz.b_buffered;

import org.junit.Test;

import java.io.*;

/*
    缓冲字符流
 */
public class BufferedDemo02 {
    @Test
    public void test01() throws IOException {
        //缓冲输入流对象
        BufferedReader br =
                new BufferedReader(
                        new FileReader("reader1.txt"));

        //定义每次读取的一行数据
        String line;
        while((line = br.readLine()) != null){
            System.out.println(line);
        }
    }

    @Test
    public void test02() throws IOException {
        //缓冲输出流对象
        BufferedWriter bw =
                new BufferedWriter(
                        new FileWriter("writer1.txt", true));

        bw.write('b');
        bw.write(98);
        bw.write("中");
        bw.newLine();

        //刷新
        bw.flush();
    }
}










